﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using XbsWebAPI.Application;
using XbsWebAPI.Core.Repositories;
using XbsWebAPI.MainHost.Tools;

namespace XbsWebAPI.MainHost.Controllers
{
    [ApiController]
    [Route("api/xbs_v1/[controller]")]
    public class MiniProgrammController : Controller
    {
        private readonly IMiniProgramAppService _miniProgramAppService;

        public MiniProgrammController(IMiniProgramAppService miniProgramAppService)
        {
            _miniProgramAppService = miniProgramAppService;
        }

        /// <summary>
        /// 设置小程序基本信息
        /// </summary>
        /// <param name="model">基本设置对象</param>
        /// <returns></returns>
        [HttpPost, Route("[action]")]
        public async Task<ResultDto<string>> SetMiniProgramm(SetMiniProgramDto model)
        {
            var result = await _miniProgramAppService.SetMiniProgram(model, WebPath.Path);
            return result;
        }

        /// <summary>
        /// 查找小程序设置基本信息
        /// </summary>
        /// <returns></returns>
        [HttpGet, Route("[action]")]
        public ResultDto<SetMiniProgramDto> FindMiniProgram()
        {
            var result = _miniProgramAppService.GetMiniProgram();
            return result;
        }
    }
}
